package com.fancy.controller;

import com.fancy.pojo.JpaUser;
import com.fancy.pojo.UserReq;
import com.fancy.service.ILoginService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class LoginController {

    @Resource
    ILoginService loginService;

    @RequestMapping("/login")
    public String login(@RequestBody JpaUser jpauser) {
        return loginService.login(jpauser);
    }

    @RequestMapping("/sendMail")
    public String sendMail(@RequestBody Map map){
        Object email = map.get("email");
        return loginService.sendMail(email.toString());
    }

    @RequestMapping("/registry")
    public String registry(@RequestBody UserReq userReq){
        return loginService.registry(userReq);
    }
}
